<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
<script type="text/javascript">
	/*升序*/
	const arr1=[5,6,1,2,4,15,7]
	arr1.sort((a,b)=>{
		return a-b
	})
	console.log(arr1)

	/*降序*/
	const arr2=[5,6,1,2,4,15,7]
	arr2.sort((a,b)=>{
		return b-a
	})
	console.log(arr2)
</script>
</body>
</html>